﻿<script type="text/javascript">


    function ClearForm() {



        $('#txtReportDate').datebox('clear');
        $('#txtAgentWorkID').textbox('clear');
        $('#txtAmbulanceNumber').textbox('clear');
        $('#txtID').val('');
        $('#txtAmbulanceCode').val('');
        $('#txtStationCode').val('');
        $('#txtCenterCode').val('');
        $('#txtStationName').textbox('clear');
        $('#txtBanCi').textbox('clear');
        $('#txtTaskTimes').textbox('clear');
        $('#txtDriverName').textbox('clear');
        $('#txtPRTimes').textbox('clear');
        $('#txtEmptyTimes').textbox('clear');
        $('#txtInvoiceNumberTotal').textbox('clear');
        $('#txtPRPrintTimes').textbox('clear');

        $('#txtbaidufei').val('');
        $('#txtCarFee').numberbox('clear');
        $('#txtWaitingFee').val('');
        $('#txtEmergencyFee').numberbox('clear');
        $('#txtDrugFeeTotal').numberbox('clear');
        $('#txtExamineFeeTotal').numberbox('clear');
        $('#txtConsumableFeeTotal').numberbox('clear');
        $('#txtMeasureFeeTotal').numberbox('clear');
        $('#txtPRFeeTotal').numberbox('clear');
        $('#txtReceivableTotal').numberbox('clear');
        $('#txtPaidMoney').numberbox('clear');
        $('#txtInvoiceNumberString').textbox('clear');
        $('#txtUselessInvoiceString').textbox('clear');

        $('#txtOffDutyKM').numberbox('clear');
        $('#txtOnDutyKM').numberbox('clear');
        $('#txtDayKM').numberbox('clear');
        $('#txtRefuelLitre').numberbox('clear');
        $('#txtOnDutyDipstick').numberbox('clear');
        $('#txtOffDutyDipstick').numberbox('clear');
        $('#txtOilConsumption').numberbox('clear');
        $('#txtRefuelInvoiceNumber').textbox('clear');
        $('#txtRemark').textbox('clear');
        $('#txtCarFeeTotal').numberbox('clear');

        $('#txtPaidPRFee').numberbox('clear');//2017-11-09
        $('#txtPaidCarFee').numberbox('clear');//2017-11-09
        $('#txtEmptyInvoiceString').textbox('clear');
        $('#txtNextMaintainKM').numberbox('clear');//2020-09-16
        $('#txtRefuelMoney').textbox('clear');

        $('#txtXJMoney').numberbox('clear'); //add2021-10-14 plq 配合医保上线新增三字段
        $('#txtYBMoney').numberbox('clear');
        $('#txtMLMoney').numberbox('clear');

        ifmessageKM = false;
    }

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
    //初始化
    function initFill(rowid) {

        var urlstr1 = '@Url.Content("~/DD/DriverReport/getPickedDoctor?RowID=")' + rowid;
        $("#txtDoctorName").combobox({
            url: urlstr1,
            valueField: 'ID',
            textField: 'Name',
            editable: false,
            multiple: false,
            panelHeight: 'auto'
        });
        var urlstr2 = '@Url.Content("~/DD/DriverReport/getPickedNurse?RowID=")' + rowid;
        $("#txtNurseName").combobox({
            url: urlstr2,
            valueField: 'ID',
            textField: 'Name',
            editable: false,
            multiple: false,
            panelHeight: 'auto'
        });
        var urlstr3 = '@Url.Content("~/DD/DriverReport/getPickedStretcher?RowID=")' + rowid;
        $("#txtStretcher1Name").combobox({
            url: urlstr3,
            valueField: 'ID',
            textField: 'Name',
            editable: false,
            multiple: false,
            panelHeight: 'auto'
        });
        //获取不正常用车原因下拉框
        var urlstr4 = '@Url.Content("~/CM/CarBasicInfo/getDictionarybyTypeID?TypeID=DPAbnormalR")';
        $("#txtAbnormalReson").combobox({
            url: urlstr4,
            valueField: 'ID',
            textField: 'Name',
            editable: false,
            multiple: false,
            panelHeight: 'auto'
        });
        IFExistReport(rowid);
    }

    //通过主表的FillState 来判断是否已填写过   ，是修改还是新增？
    function IFExistReport(rowid) {
        $.ajax({
            type: 'POST',
            url: '@Url.Content("~/DD/DriverReport/IFExistReportDate")',
            data:
                {
                    RowID: rowid
                },
            dataType: "json",
            success: function (jsData) {

                //通过主表的FillState 来判断是否已填写过 主表
                var FillState = jsData.drinfo.FillState;
                var ReportState = jsData.drinfo.ReportState;
                if (ReportState != null && ReportState == "已勾选") {
                    $.messager.alert('警告', '已被分站长勾选，不能修改！');
                }
                    //进入 编辑
                else {
                    var tempreportdate = $.formatDate(jsData.drinfo.ReportDate);
                    //先将昨天的下班路码和下班油尺取出来赋值给全局变量
                    $.ajax({
                        type: 'POST',
                        url: '@Url.Content("~/DD/DriverReport/GetoffDuty")',
                        data:
                            {
                                SAmbulance: jsData.drinfo.AmbulanceNumber ? jsData.drinfo.AmbulanceNumber : SAmbulance,
                                // SAmbulance: SAmbulance ? SAmbulance : jsData.drinfo.AmbulanceNumber,   //跟根据车来取昨天的下班路码  2016 -3 15
                                // DworkID: DworkID,
                                ReportDate: tempreportdate

                            },
                        dataType: "json",
                        success: function (jsDataz) {
                            //全局变量 下班路码，下班油尺,下次保养日期
                            YesdayOffDutyKM = jsDataz.OffInfo.OffDutyKM ? jsDataz.OffInfo.OffDutyKM : 0;
                            YesdayOffDutyDipstick = jsDataz.OffInfo.OffDutyDipstick ? jsDataz.OffInfo.OffDutyDipstick : 0;
                            NextMaintainKM = jsDataz.OffInfo.NextMaintainKM ? jsDataz.OffInfo.NextMaintainKM : 0;

                            // 这里是修改
                            if (FillState == "已填写日报") {
                                ClearForm();
                                $('#FillDetailDialog').dialog('open');

                                $("#txtDoctorName").combobox('setValues', jsData.drinfo.DoctorName);
                                $("#txtNurseName").combobox('setValues', jsData.drinfo.NurseName);
                                $("#txtStretcher1Name").combobox('setValues', jsData.drinfo.Stretcher1Name);

                                $('#txtID').val(jsData.drinfo.ID);
                                $('#txtReportDate').datebox('setValue', jsData.drinfo.ReportDate);
                                $('#txtAgentWorkID').textbox('setValue', jsData.drinfo.AgentWorkID);//
                                $('#txtAmbulanceNumber').textbox('setValue', jsData.drinfo.AmbulanceNumber);//
                                $('#txtAmbulanceCode').val(jsData.drinfo.AmbulanceCode);
                                $('#txtStationCode').val(jsData.drinfo.StationCode);
                                $('#txtCenterCode').val(jsData.drinfo.CenterCode);
                                $('#txtStationName').textbox('setValue', jsData.drinfo.StationName);
                                $('#txtBanCi').textbox('setValue', jsData.drinfo.BanCi);
                                $('#txtTaskTimes').textbox('setValue', jsData.drinfo.TaskTimes);
                                $('#txtDriverName').textbox('setValue', jsData.drinfo.DriverName);
                                $('#txtPRTimes').textbox('setValue', jsData.drinfo.PRTimes);
                                $('#txtEmptyTimes').textbox('setValue', jsData.drinfo.EmptyTimes);//
                                $('#txtPRPrintTimes').textbox('setValue', jsData.drinfo.PRPrintTimes);//2016-5-13 新增

                                $('#txtInvoiceNumberTotal').textbox('setValue', jsData.drinfo.InvoiceNumberTotal);//发票份数

                                $('#txtbaidufei').val(jsData.drinfo.baidufei);
                                $('#txtCarFee').numberbox('setValue', jsData.drinfo.CarFee);

                                $('#txtPaidCarFee').numberbox('setValue', jsData.drinfo.PaidCarFee ? jsData.drinfo.PaidCarFee : 0);   //2017-11-09

                                //车费+等车费+摆渡费
                                $('#txtCarFeeTotal').numberbox('setValue', jsData.drinfo.CarFee + jsData.drinfo.baidufei + jsData.drinfo.WaitingFee);


                                $('#txtWaitingFee').val(jsData.drinfo.WaitingFee);
                                $('#txtEmergencyFee').numberbox('setValue', jsData.drinfo.EmergencyFee);
                                $('#txtDrugFeeTotal').numberbox('setValue', jsData.drinfo.DrugFeeTotal);
                                $('#txtExamineFeeTotal').numberbox('setValue', jsData.drinfo.ExamineFeeTotal);
                                $('#txtConsumableFeeTotal').numberbox('setValue', jsData.drinfo.ConsumableFeeTotal);
                                $('#txtMeasureFeeTotal').numberbox('setValue', jsData.drinfo.MeasureFeeTotal);
                                $('#txtPRFeeTotal').numberbox('setValue', jsData.drinfo.PRFeeTotal);

                                $('#txtPaidPRFee').numberbox('setValue', jsData.drinfo.PaidPRFee ? jsData.drinfo.PaidPRFee : 0); //2017-11-09

                                $('#txtReceivableTotal').numberbox('setValue', jsData.drinfo.ReceivableTotal);
                                $('#txtPaidMoney').numberbox('setValue', jsData.drinfo.PaidMoney);
                                $('#txtInvoiceNumberString').textbox('setValue', jsData.drinfo.InvoiceNumberString);
                                $('#txtUselessInvoiceString').textbox('setValue', jsData.drinfo.UselessInvoiceString);//

                                $('#txtEmptyInvoiceString').textbox('setValue', jsData.drinfo.EmptyInvoiceString);//

                                $('#txtRemark').textbox('setValue', jsData.drinfo.Remark);//

                                $('#txtOffDutyKM').numberbox('setValue', jsData.drinfo.OffDutyKM);//
                                $('#txtOnDutyKM').numberbox('clear');
                                $('#txtOnDutyKM').numberbox('setValue', jsData.drinfo.OnDutyKM);//
                                $('#txtDayKM').numberbox('setValue', jsData.drinfo.DayKM);//
                                $('#txtRefuelLitre').numberbox('setValue', jsData.drinfo.RefuelLitre);//
                                $('#txtOnDutyDipstick').numberbox('clear');
                                $('#txtOnDutyDipstick').numberbox('setValue', jsData.drinfo.OnDutyDipstick);//
                                $('#txtOffDutyDipstick').numberbox('setValue', jsData.drinfo.OffDutyDipstick);//
                                $('#txtOilConsumption').numberbox('setValue', jsData.drinfo.OilConsumption);//
                                $('#txtRefuelInvoiceNumber').textbox('setValue', jsData.drinfo.RefuelInvoiceNumber);//
                                $('#txtNextMaintainKM').numberbox('setValue', jsData.drinfo.NextMaintainKM);
                                $('#txtRefuelMoney').textbox('setValue', jsData.drinfo.RefuelMoney);

                                $('#txtXJMoney').numberbox('setValue', jsData.drinfo.XJMoney); //add2021-10-14 plq 医保上线新增三明细字段
                                $('#txtYBMoney').numberbox('setValue', jsData.drinfo.YBMoney);
                                $('#txtMLMoney').numberbox('setValue', jsData.drinfo.MLMoney);

                                getChargeSum("#txtOffDutyKM");

                                getChargeSum2("#txtOffDutyDipstick");
                                getChargeSum2("#txtRefuelLitre");
                                setpPToolTip();

                                var tempkm = jsData.drinfo.AbnormalKM ? jsData.drinfo.AbnormalKM : 0;
                                var tempoil = jsData.drinfo.AbnormalOil ? jsData.drinfo.AbnormalOil : 0;

                                //编辑的时候如果 有不正常用车的话，将内容填充到页面上
                                if (tempkm > 0 || tempoil > 0) {

                                    $('#txtAbnormalKM').numberbox('setValue', jsData.drinfo.AbnormalKM);
                                    $('#txtAbnormalOil').numberbox('setValue', jsData.drinfo.AbnormalOil);
                                    $('#txtAbnormalReson').combobox('setValue', jsData.drinfo.AbnormalReson);
                                    showAbnormal();//不正常用车
                                } else {
                                    hideAbnormal();//隐藏不正常用车
                                }

                                ifmessageKM = true;
                            }
                                //新增--日报未填写时
                            else {
                                getALLFill(rowid);
                                hideAbnormal();//隐藏不正常用车
                            }
                            changeKMandOil();
                        }//ajax 取昨天的下班路码
                    });
                }//进入编辑
            } //success
        });
    }
    function changeKMandOil() {
        //上班路码和上班油尺有改变的时候判断
        $('#txtOnDutyKM').numberbox({
            onChange: function (newV, oldV) {

                if (newV > YesdayOffDutyKM) {

                    showAbnormal();
                    //将新填写的值与昨天下班路码的相减结果赋值给非正常公里
                    var tempnewv = Number(newV) - Number(YesdayOffDutyKM);
                    $('#txtAbnormalKM').numberbox('setValue', tempnewv);
                    $('#txtAbnormalReson').combobox({ required: true });
                    getChargeTotal();

                }
                else {
                    if (newV < YesdayOffDutyKM) {
                        hideAbnormal();
                        //  上班路码修改小于昨天下班路码的提醒   2016 - 4 - 25
                        //$.messager.confirm('系统检测', '您修改的上班路码小于昨天该车的下班路码，请确认填写是否正确！', function (r) {
                        //    if (r) {

                        //    }
                        //    else {
                        //        $('#txtOnDutyKM').numberbox('setValue', oldV);
                        //    }
                        //});
                        //2016-6-22 新增上班路码改变，计算公里数
                        getChargeTotal();
                    }
                    $('#txtAbnormalKM').numberbox('clear');
                    $('#txtAbnormalReson').combobox('clear');
                    $('#txtAbnormalReson').combobox({ required: false });
                }
            }
        });

        $('#txtOnDutyDipstick').numberbox({
            onChange: function (newV, oldV) {
                if (newV < YesdayOffDutyDipstick) {

                    showAbnormal();
                    //将新填写的值与昨天下班路码的相减结果赋值给非正常公里
                    var tempnewv = Number(YesdayOffDutyDipstick) - Number(newV);
                    $('#txtAbnormalOil').numberbox('setValue', tempnewv);
                }
                else {
                    if (newV > oldV) {
                        //alert("提示，只能填写大于 昨天下班路码");
                        //$('#txtOnDutyKM').numberbox('clear');
                        // hideAbnormal();
                    }
                    $('#txtAbnormalOil').numberbox('clear');
                    // $('#txtAbnormalReson').combobox('clear');
                }
            }
        });
        $('#txtDayKM').numberbox({
            onChange: function (newV, oldV) {
                if (newV > 500 && ifmessageKM == true) {
                    //新增公里数大于500 提醒  2016-4-25

                    $.messager.alert('提示信息', '您填写的公里数已大于500，请确认填写是否正确！')

                }

            }
        });


    }
    //是否提醒公里数大于500km 全局变量 用于在message alert 的时候提醒 只在新增的时候会变true  2016-4-25
    var ifmessageKM = false;


    //获取所有页面可取值的 然后赋值
    function getALLFill(rowid) {
        ClearForm();
        $('#FillDetailDialog').dialog('open');

        //将昨天的下班路码赋值给今天的上班路码,昨天的下班油尺赋值给今天的上班油尺 2016-03-02
        $('#txtOnDutyKM').numberbox('setValue', YesdayOffDutyKM);//
        $('#txtOnDutyDipstick').numberbox('setValue', YesdayOffDutyDipstick);//
        $('#txtNextMaintainKM').numberbox('setValue', NextMaintainKM);//
        $.ajax({
            type: 'POST',
            url: '@Url.Content("~/DD/DriverReport/getPickedAmbulanceLink")',
            data:
                {
                    RowID: rowid
                },
            dataType: "json",
            success: function (jsData) {
                if (jsData.drinfo.ReportDate != null) {
                    var tempNonPReportDate = $.formatDate(jsData.drinfo.ReportDate);//保险
                    //赋值给页面控件
                    $('#txtReportDate').datebox('setValue', tempNonPReportDate);
                }
                $('#txtAgentWorkID').textbox('setValue', jsData.drinfo.AgentWorkID);//
                $('#txtAmbulanceNumber').textbox('setValue', jsData.drinfo.AmbulanceNumber);//
                $('#txtAmbulanceCode').val(jsData.drinfo.AmbulanceCode);
                $('#txtStationCode').val(jsData.drinfo.StationCode);
                $('#txtCenterCode').val(jsData.drinfo.CenterCode);
                $('#txtStationName').textbox('setValue', jsData.drinfo.StationName);
                $('#txtBanCi').textbox('setValue', jsData.drinfo.BanCi);
                $('#txtTaskTimes').textbox('setValue', jsData.drinfo.TaskTimes);
                $('#txtDriverName').textbox('setValue', jsData.drinfo.DriverName);
            }
        });

        $.ajax({
            type: 'POST',
            url: '@Url.Content("~/DD/DriverReport/getPickedFeeLink")',
            data:
                {
                    RowID: rowid
                },
            dataType: "json",
            success: function (jsData) {

                //赋值给页面控件
                $('#txtPRTimes').textbox('setValue', jsData.FLinfo.PRTimes);
                $('#txtEmptyTimes').textbox('setValue', jsData.FLinfo.EmptyTimes);//
                $('#txtInvoiceNumberTotal').textbox('setValue', jsData.FLinfo.InvoiceNumberTotal);//发票份数

                $('#txtbaidufei').val(jsData.FLinfo.baidufei);
                $('#txtCarFee').numberbox('setValue', jsData.FLinfo.CarFee);
                $('#txtWaitingFee').val(jsData.FLinfo.WaitingFee);
                $('#txtCarFeeTotal').numberbox('setValue', jsData.FLinfo.CarFee + jsData.FLinfo.baidufei + jsData.FLinfo.WaitingFee);

                $('#txtPaidCarFee').numberbox('setValue', jsData.FLinfo.PaidCarFee); //2017-11-09
                $('#txtPaidPRFee').numberbox('setValue', jsData.FLinfo.PaidPRFee); //2017-11-09


                $('#txtEmergencyFee').numberbox('setValue', jsData.FLinfo.EmergencyFee);
                $('#txtDrugFeeTotal').numberbox('setValue', jsData.FLinfo.DrugFeeTotal);
                $('#txtExamineFeeTotal').numberbox('setValue', jsData.FLinfo.ExamineFeeTotal);
                $('#txtConsumableFeeTotal').numberbox('setValue', jsData.FLinfo.ConsumableFeeTotal);
                $('#txtMeasureFeeTotal').numberbox('setValue', jsData.FLinfo.MeasureFeeTotal);
                $('#txtPRFeeTotal').numberbox('setValue', jsData.FLinfo.PRFeeTotal);
                $('#txtReceivableTotal').numberbox('setValue', jsData.FLinfo.ReceivableTotal);
                $('#txtPaidMoney').numberbox('setValue', jsData.FLinfo.PaidMoney);
                $('#txtWaitingandBaiduFee').numberbox('setValue', jsData.FLinfo.baidufei + jsData.FLinfo.WaitingFee);

                $('#txtXJMoney').numberbox('setValue', jsData.FLinfo.XJMoney); //add2021-10-14 plq 配合医保上线，新增三字段
                $('#txtYBMoney').numberbox('setValue', jsData.FLinfo.YBMoney);
                $('#txtMLMoney').numberbox('setValue', jsData.FLinfo.MLMoney);

                //tooltip 的加载
                setpPToolTip();
            }
        });

        $.ajax({
            type: 'POST',
            url: '@Url.Content("~/DD/DriverReport/getPickedFPLink")',
            data:
                {
                    RowID: rowid
                },
            dataType: "json",
            success: function (jsData) {
                //赋值给页面控件
                $('#txtInvoiceNumberString').textbox('setValue', jsData.FPLinfo.InvoiceNumberString);
                $('#txtUselessInvoiceString').textbox('setValue', jsData.FPLinfo.UselessInvoiceString);//

                $('#txtEmptyInvoiceString').textbox('setValue', jsData.FPLinfo.EmptyInvoiceString);//

            }
        });

        var data1 = $('#txtDoctorName').combobox('getData');  //赋默认值
        if (data1.length > 0) {
            $("#txtDoctorName").combobox('select', data1[0].ID);
        }
        var data2 = $('#txtNurseName').combobox('getData');  //赋默认值
        if (data2.length > 0) {
            $("#txtNurseName").combobox('select', data2[0].ID);
        }
        var data3 = $('#txtStretcher1Name').combobox('getData');  //赋默认值
        if (data3.length > 0) {
            $("#txtStretcher1Name").combobox('select', data3[0].ID);
        }
        $('#txtID').val(rowid);   //将传进来的ID 赋值给隐藏ID

        getChargeSum("#txtOffDutyKM");

        getChargeSum2("#txtOffDutyDipstick");
        getChargeSum2("#txtRefuelLitre");

        ifmessageKM = true;

    }//给页面赋值结束标志




    function setpPToolTip() {
        var pTimesDetial = ' 等车费：' + $('#txtWaitingFee').val() + ' 元， 摆渡费：' + $('#txtbaidufei').val() + ' 元';
        //此段内容为，ajax取 急救、转院、回家的出车数 ，然后赋值给content 的内容。显示在tooltip里。
        $('#ptooltipTT').tooltip({
            position: 'top',
            content: pTimesDetial,
            onShow: function () {
                $(this).tooltip('tip').css({
                    backgroundColor: '#DCDAEF',
                    borderColor: '#DCDAEF'
                });
            }
        });
    }

    function submitAddForm() { //提交新增方法
        var submtxtDayKM = $('#txtDayKM').numberbox('getValue');
        var reduceKM = $('#txtOffDutyKM').numberbox('getValue') - $('#txtOnDutyKM').numberbox('getValue');

        if (submtxtDayKM > 500 || reduceKM > 500 || submtxtDayKM == 0 || reduceKM <= 0) {
            $.messager.confirm('系统检测', '您填写的路码或公里数有异常，请确认填写是否正确！', function (r) {
                if (r) {

                    if ($('#txtReceivableTotal').numberbox('getValue') != $('#txtPaidMoney').numberbox('getValue')) {
                        if ($('#txtRemark').textbox('getValue').length == 0) {
                            $.messager.confirm('系统检测', '应收实收不符，请填写备注！', function () {
                            });
                        }
                        else {
                            $('#formSubmit').form('submit', {
                                url: '@Url.Content("~/DD/DriverReport/SaveFillReport")',
                                queryParams: {
                                    LastModifier: LastModifier,
                                    zDoctorName: $('#txtDoctorName').combobox('getValues'),
                                    zNurseName: $('#txtNurseName').combobox('getValues'),
                                    zStretcher1Name: $('#txtStretcher1Name').combobox('getValues')
                                },
                                onSubmit: function () {
                                    return $(this).form('validate');
                                },
                                success: function (data) {
                                    var jsData = $.parseJSON(data);

                                    $.showMsg(jsData.Message, "系统提示", function () { });
                                    $('#FillDetailDialog').dialog('close');
                                    $('#DriverReportMain').datagrid('reload');
                                    ClearForm();
                                }
                            });
                        }
                    }
                    else {
                        $('#formSubmit').form('submit', {
                            url: '@Url.Content("~/DD/DriverReport/SaveFillReport")',
                            queryParams: {
                                LastModifier: LastModifier,
                                zDoctorName: $('#txtDoctorName').combobox('getValues'),
                                zNurseName: $('#txtNurseName').combobox('getValues'),
                                zStretcher1Name: $('#txtStretcher1Name').combobox('getValues')

                            },
                            onSubmit: function () {
                                return $(this).form('validate');
                            },
                            success: function (data) {
                                var jsData = $.parseJSON(data);

                                $.showMsg(jsData.Message, "系统提示", function () { });
                                $('#FillDetailDialog').dialog('close');
                                $('#DriverReportMain').datagrid('reload');
                                ClearForm();
                            }
                        });
                    }
                }
                else {

                }
            });
        }
            //如果数据无异常，正常提交
        else {
            if ($('#txtReceivableTotal').numberbox('getValue') != $('#txtPaidMoney').numberbox('getValue')) {
                if ($('#txtRemark').textbox('getValue').length == 0) {

                    $.messager.confirm('系统检测', '应收实收不符，请填写备注！', function () {
                    });
                }
                else {
                    $('#formSubmit').form('submit', {
                        url: '@Url.Content("~/DD/DriverReport/SaveFillReport")',
                        queryParams: {
                            LastModifier: LastModifier,
                            zDoctorName: $('#txtDoctorName').combobox('getValues'),
                            zNurseName: $('#txtNurseName').combobox('getValues'),
                            zStretcher1Name: $('#txtStretcher1Name').combobox('getValues')

                        },
                        onSubmit: function () {
                            return $(this).form('validate');
                        },
                        success: function (data) {
                            var jsData = $.parseJSON(data);

                            $.showMsg(jsData.Message, "系统提示", function () { });
                            $('#FillDetailDialog').dialog('close');
                            $('#DriverReportMain').datagrid('reload');
                            ClearForm();
                        }
                    });
                }
            }
            else {
                $('#formSubmit').form('submit', {
                    url: '@Url.Content("~/DD/DriverReport/SaveFillReport")',
                    queryParams: {
                        LastModifier: LastModifier,
                        zDoctorName: $('#txtDoctorName').combobox('getValues'),
                        zNurseName: $('#txtNurseName').combobox('getValues'),
                        zStretcher1Name: $('#txtStretcher1Name').combobox('getValues')

                    },
                    onSubmit: function () {
                        return $(this).form('validate');
                    },
                    success: function (data) {
                        var jsData = $.parseJSON(data);

                        $.showMsg(jsData.Message, "系统提示", function () { });
                        $('#FillDetailDialog').dialog('close');
                        $('#DriverReportMain').datagrid('reload');
                        ClearForm();
                    }
                });
            }
        }
    }

    //路码表 与油尺  改变的小判断
    function getChargeSum(cid) {
        $(cid).numberbox({
            onChange: function (newV, oldV) {
                getChargeTotal();
            }
        });
    }
    //路码表 与油尺改变的判断。
    function getChargeTotal() {
        var a = $('#txtOffDutyKM').numberbox('getValue');
        var b = $('#txtOnDutyKM').numberbox('getValue');
        var KMTotal = Number(a) - Number(b);
        if (KMTotal <= 0) {
            $('#txtDayKM').numberbox('setValue', 0);
        }
        else { $('#txtDayKM').numberbox('setValue', KMTotal); }
    }

    function getChargeSum2(cid) {
        $(cid).numberbox({
            onChange: function (newV, oldV) {
                getChargeTotal2();
            }
        });
    }
    //油尺改变的判断。  上班油尺+加油量-下班油尺 =本班耗油
    function getChargeTotal2() {
        var a = $('#txtOnDutyDipstick').numberbox('getValue');
        var b = $('#txtOffDutyDipstick').numberbox('getValue');
        var add = $('#txtRefuelLitre').numberbox('getValue') ? $('#txtRefuelLitre').numberbox('getValue') : 0;
        var KMTotal1 = Number(a) + Number(add) - Number(b);
        if (KMTotal1 <= 0) {
            $('#txtOilConsumption').numberbox('setValue', 0);
        }
        else { $('#txtOilConsumption').numberbox('setValue', KMTotal1); }
    }

    //隐藏不正常公里和耗油
    function hideAbnormal() {
        document.getElementById("HideabnormalKM").style.display = "none";
        document.getElementById("HideAbnormalOil").style.display = "none";
    }

    //显示不正常公里和耗油
    function showAbnormal() {
        document.getElementById("HideabnormalKM").style.display = "block";
        document.getElementById("HideAbnormalOil").style.display = "block";
    }


</script>

<div id="FillDetailDialog" class="easyui-dialog" title="填写日报表"
     data-options="modal:true,
     collapsible:false,
     minimizable:false,
     maximizable:false,
     closed:true,
     resizable:false,
     iconCls:'icon-custom-cWuZiWeiHu',
     onClose:function(){ ClearForm();}"
     style="width: 1100px; height: auto; padding: 10px;">
    <form id="formSubmit" method="post">
        <input name="ID" id="txtID" type="hidden">
        <input name="WaitingFee" id="txtWaitingFee" type="hidden">
        <input name="baidufei" id="txtbaidufei" type="hidden">


        <div style="width: 99%; height: auto;">
            <table border="0" style="width:99%;height:auto;">
                <tr>
                    <td align="center" colspan="6">
                        <span style="font-size: large; ">车辆工作日报表</span>
                    </td>

                </tr>
                <tr>
                    <td align="center">日报日期:</td>
                    <td><input class="easyui-datebox" style="width: 140px" name="ReportDate" id="txtReportDate" data-options="readonly:true"></td>

                    <td align="center">
                        填写人工号：
                    </td>
                    <td>
                        <input class="easyui-textbox" style="width: 130px" name="AgentWorkID" id="txtAgentWorkID" data-options="readonly:true">
                    </td>
                    <td align="center">
                        车&nbsp;&nbsp;号：
                    </td>
                    <td>
                        <input class="easyui-textbox" style="width: 130px" name="AmbulanceNumber" id="txtAmbulanceNumber" data-options="readonly:true">
                        <input name="AmbulanceCode" id="txtAmbulanceCode" type="hidden">
                    </td>
                    <td align="center">
                        <a href="javascript:void(0)" id="btnadd" style="width: 60px; height: 30px; color:#0026ff;" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="submitAddForm();">提交</a>
                    </td>
                </tr>
                <tr>
                    <td valign="top" colspan="5">

                        <div class="easyui-accordion" style="width: 100%; height: auto;">
                            <div title="任务信息" data-options="iconCls:'icon-save'" style="overflow:auto;padding:1px;">
                                <table border="0">
                                    <tr>
                                        <td style="width:100px" align="right">  分站：</td>
                                        <td style="width:125px">
                                            <input class="easyui-textbox" style="width: 120px" name="StationName" id="txtStationName" data-options="readonly:true">
                                            <input name="StationCode" id="txtStationCode" type="hidden">
                                            <input name="CenterCode" id="txtCenterCode" type="hidden">
                                        </td>
                                        <td align="right" style="width:75px">
                                            班次：
                                        </td>
                                        <td style="width:125px">
                                            <input class="easyui-textbox" style="width: 120px" name="BanCi" id="txtBanCi" data-options="readonly:true">
                                        </td>
                                        <td align="right" style="width:100px">
                                            车次：
                                        </td>
                                        <td style="width:125px">
                                            <input class="easyui-textbox" style="width: 60px" name="TaskTimes" id="txtTaskTimes" data-options="readonly:true">
                                        </td>
                                    </tr>

                                    <tr>
                                        <td align="right">
                                            司机：
                                        </td>
                                        <td>
                                            <input class="easyui-textbox" style="width: 170px" name="DriverName" id="txtDriverName">
                                        </td>
                                        <td align="right">
                                            医生：
                                        </td>
                                        <td>
                                            <input name="DoctorName" id="txtDoctorName" class="easyui-combobox" style="width: 170px" />

                                        </td>
                                        <td align="right">
                                            救护数：
                                        </td>
                                        <td>
                                            <input class="easyui-textbox" style="width: 60px" name="PRTimes" id="txtPRTimes" data-options="readonly:true">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right">
                                            护士：
                                        </td>
                                        <td>
                                            <input class="easyui-combobox" style="width: 170px" name="NurseName" id="txtNurseName">
                                        </td>
                                        <td align="right">
                                            担架员：
                                        </td>
                                        <td>
                                            <input class="easyui-combobox" style="width: 170px" name="Stretcher1Name" id="txtStretcher1Name">
                                        </td>
                                        <td align="right">
                                            空车数：
                                        </td>
                                        <td>
                                            <input class="easyui-textbox" style="width: 60px" name="EmptyTimes" id="txtEmptyTimes" data-options="readonly:true">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="left" colspan="4">
                                            随车记录卡号码 &nbsp;&nbsp;

                                            (共<input class="easyui-textbox" style="width: 40px;" name="InvoiceNumberTotal" id="txtInvoiceNumberTotal" data-options="readonly:true">份)
                                        </td>
                                        <td align="right" style="color:red;">
                                            病历打印数：
                                        </td>
                                        <td>
                                            <input class="easyui-textbox" style="width: 60px" name="PRPrintTimes" id="txtPRPrintTimes" data-options="required:true">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="6"><input class="easyui-textbox" style="width: 720px" name="InvoiceNumberString" id="txtInvoiceNumberString" data-options="readonly:true"></td>

                                    </tr>
                                    <tr>
                                        <td align="left">重打发票号</td>
                                        <td colspan="5"> <input class="easyui-textbox" style="width: 640px" name="UselessInvoiceString" id="txtUselessInvoiceString" data-options="readonly:true"></td>
                                    </tr>
                                    <tr>
                                        <td align="left">空车中止发票号</td>
                                        <td colspan="5"> <input class="easyui-textbox" style="width: 640px" name="EmptyInvoiceString" id="txtEmptyInvoiceString" data-options="readonly:true"></td>
                                    </tr>
                                    <tr>
                                        <td align="center" colspan="6" style="color:#0099FF; font-size:medium" height="30px">
                                            收 &nbsp;费 &nbsp;情 &nbsp;况
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right">
                                            救护车费：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="CarFee" id="txtCarFee" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                        <td align="right">
                                            <label id="ptooltipTT">其他费用:</label>
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="WaitingandBaiduFee" id="txtWaitingandBaiduFee" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                        <td align="right">
                                            车费合计：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" id="txtCarFeeTotal" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                        <td></td>
                                        <td></td>


                                    </tr>
                                    <tr>
                                        <td align="right">
                                            院前急救费：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="EmergencyFee" id="txtEmergencyFee" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                        <td align="right">
                                            药 &nbsp;费：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="DrugFeeTotal" id="txtDrugFeeTotal" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                        <td align="right">
                                            材料费：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="ConsumableFeeTotal" id="txtConsumableFeeTotal" data-options="precision:2,prefix:'￥',readonly:true"></td>

                                    </tr>
                                    <tr>
                                        <td align="right">
                                            检查费：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="ExamineFeeTotal" id="txtExamineFeeTotal" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                        <td align="right">
                                            治疗费：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="MeasureFeeTotal" id="txtMeasureFeeTotal" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                        <td align="right">
                                            医疗费合计：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="PRFeeTotal" id="txtPRFeeTotal" data-options="precision:2,prefix:'￥',readonly:true"></td>

                                    </tr>

                                    <tr>

                                        <td align="right">
                                            应收合计：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="ReceivableTotal" id="txtReceivableTotal" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                        <td align="right" style="color:red">
                                            车费实收：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="PaidCarFee" id="txtPaidCarFee" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                        <td align="right" style="color:red">
                                            医疗费实收：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="PaidPRFee" id="txtPaidPRFee" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                        
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td align="right" style="color:red">
                                            实收合计：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="PaidMoney" id="txtPaidMoney" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                    </tr>
                                    <tr>
                                        <td align="right" style="color:red">
                                            现金收费：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="XJMoney" id="txtXJMoney" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                        <td align="right" style="color:red">
                                            医保收费：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="YBMoney" id="txtYBMoney" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                        <td align="right" style="color:red">
                                            分币误差：
                                        </td>
                                        <td><input class="easyui-numberbox" style="width: 120px" name="MLMoney" id="txtMLMoney" data-options="precision:2,prefix:'￥',readonly:true"></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td align="right" height="40px">
                                            备注：
                                        </td>
                                        <td colspan="5"><input class="easyui-textbox" style="width: 630px" name="Remark" id="txtRemark"></td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </td>
                    <td valign="top" width="270px" colspan="2">
                        <table border="0" style="width:270px">
                            <tr>
                                <td>
                                    <div class="easyui-accordion" style="width: 100%; height:inherit;">
                                        <div title="里程情况" data-options="iconCls:'icon-save'" style="overflow:auto;padding:1px;">
                                            <table id="ReportInfo">
                                                <tr style="height:30px"><td style="color:#0099FF;">路码表</td></tr>
                                                <tr style="height:30px">
                                                    <td>
                                                        下班路码：
                                                    </td>
                                                    <td>
                                                        <input class="easyui-numberbox" style="width: 150px" name="OffDutyKM" id="txtOffDutyKM" data-options="precision:2">
                                                    </td>

                                                </tr>
                                                <tr style="height:30px">
                                                    <td>
                                                        上班路码:
                                                    </td>
                                                    <td>
                                                        <input class="easyui-numberbox" style="width: 150px" name="OnDutyKM" id="txtOnDutyKM" data-options="precision:2">
                                                    </td>

                                                </tr>
                                                <tr style="height:30px">
                                                    <td style="color:red;">
                                                        公里数:
                                                    </td>
                                                    <td>
                                                        <input class="easyui-numberbox" style="width: 150px" name="DayKM" id="txtDayKM" data-options="required:true,readonly:true,precision:2">
                                                    </td>
                                                </tr>
                                                <tr style="height:30px">
                                                    <td>
                                                        下次保养公里数:
                                                    </td>
                                                    <td>
                                                        <input class="easyui-numberbox" style="width: 150px" name="NextMaintainKM" id="txtNextMaintainKM" data-options="precision:2">
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                        <div id="HideabnormalKM">
                                                            <table>
                                                                <tr style="height:30px">
                                                                    <td style="color:red;">
                                                                        非正常公里:
                                                                    </td>
                                                                    <td>
                                                                        <input class="easyui-numberbox" style="width: 150px" name="AbnormalKM" id="txtAbnormalKM" data-options="readonly:true">
                                                                    </td>
                                                                </tr>
                                                                <tr style="height:30px">
                                                                    <td style="color:red;">
                                                                        非正常原因:
                                                                    </td>
                                                                    <td>
                                                                        <input class="easyui-combobox" style="width: 150px" name="AbnormalReson" id="txtAbnormalReson">
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </div>
                                                    </td>
                                                </tr>



                                            </table>
                                            <table id="CausePerson">
                                                <tr style="height:30px"><td style="color:#0099FF;">油脂情况</td></tr>
                                                <tr style="height:30px">
                                                    <td>
                                                        本班加油：
                                                    </td>
                                                    <td>
                                                        <input class="easyui-numberbox" style="width: 140px" name="RefuelLitre" id="txtRefuelLitre" data-options="precision:2">公升
                                                    </td>
                                                </tr>
                                                <tr style="height:30px">
                                                    <td>
                                                        加油发票号:
                                                    </td>
                                                    <td>
                                                        <input class="easyui-textbox" style="width: 140px" name="RefuelInvoiceNumber" id="txtRefuelInvoiceNumber">
                                                    </td>

                                                </tr>
                                                <tr style="height:30px">
                                                    <td>
                                                        加油金额:
                                                    </td>
                                                    <td>
                                                        <input class="easyui-textbox" style="width: 140px" name="RefuelMoney" id="txtRefuelMoney">
                                                    </td>
                                                </tr>
                                                <tr style="height:30px">
                                                    <td>
                                                        油尺上班:
                                                    </td>
                                                    <td>
                                                        <input class="easyui-numberbox" style="width: 140px" name="OnDutyDipstick" id="txtOnDutyDipstick" data-options="precision:2">公升
                                                    </td>
                                                </tr>
                                                <tr style="height:30px">
                                                    <td>
                                                        油尺下班:
                                                    </td>
                                                    <td>
                                                        <input class="easyui-numberbox" style="width: 140px" name="OffDutyDipstick" id="txtOffDutyDipstick" data-options="precision:2">公升
                                                    </td>
                                                </tr>
                                                <tr style="height:30px">
                                                    <td style="color:red;">
                                                        本班耗油:
                                                    </td>
                                                    <td>
                                                        <input class="easyui-numberbox" style="width: 140px" name="OilConsumption" id="txtOilConsumption" data-options="required:true,precision:2">公升
                                                    </td>

                                                </tr>
                                                <tr>
                                                    <td colspan="2">
                                                        <div id="HideAbnormalOil">
                                                            <table>
                                                                <tr>
                                                                    <td style="color:red;">
                                                                        非正常耗油:
                                                                    </td>
                                                                    <td>
                                                                        <input class="easyui-numberbox" style="width: 140px" name="AbnormalOil" id="txtAbnormalOil" data-options="readonly:true">公升
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </div>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                </td>
                            </tr>

                        </table>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</div>
